package MyProperties;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;
import java.util.Set;

public class demo1 {
    public static void main(String[] args) throws Exception {
        Properties properties = new Properties();
        properties.setProperty("小鸭","gagaga");
        properties.setProperty("小鸡","jijiji");
        properties.setProperty("小狗","wangwangwang");
        properties.setProperty("小猫","miaomiao");

        //将内容中的数据加载到文件中
        properties.store(new FileWriter("D:\\software\\code\\2023_java\\2023_java_code\\code_24_4_29\\src\\MyProperties\\text1.properties"),"yes");

        //将文件中的数据取出来
        properties.load(new FileReader("D:\\software\\code\\2023_java\\2023_java_code\\code_24_4_29\\src\\MyProperties\\text1.properties"));

        Set<String> set = properties.stringPropertyNames();
        for (String s : set) {
            System.out.println(s + " :" + properties.getProperty(s) );
        }

    }
}
